fix(builtins): command -v/-V now searches PATH for external scripts#1134
Merged
fix(builtins): command -v/-V now searches PATH for external scripts#1134
Conversation
command -v and command -V only checked builtins, functions, and keywords. Now they also search PATH directories on the VFS for executable scripts, matching real bash behavior. command -v prints the resolved path; command -V prints "name is /path". Closes #1120
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
command -vandcommand -Vonly checked builtins, functions, and keywords — never PATHcommand -v myscriptprints the resolved path (e.g./scripts/myscript)command -V myscriptprintsmyscript is /scripts/myscriptresolve_command_path()helper that does read-only PATH lookup without executionTest plan
command_v_finds_builtin— finds echo as builtincommand_v_finds_function— finds user-defined functionscommand_v_not_found— returns exit 1 for unknown commandscommand_v_searches_path— finds executable scripts on PATHcommand_V_builtin— "echo is a shell builtin"command_V_path_script— "pathcmd is /scripts/pathcmd"Closes #1120